package ar.edu.unlu.sistemas.ws.business;

import java.io.Serializable;
import java.util.Map;

public class ResourceDescriptionWS implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -6448165754462963189L;
	private Map<String,Integer> resourceDescription;
	private Integer nDocs;

	public Map<String, Integer> getResourceDescription() {
		return resourceDescription;
	}

	public void setResourceDescription(
			Map<String, Integer> resourceDescription) {
		this.resourceDescription = resourceDescription;
	}

	public Integer getnDocs() {
		return nDocs;
	}

	public void setnDocs(Integer nDocs) {
		this.nDocs = nDocs;
	}
	
	public void add(ResourceDescriptionWS resource) {
		this.setnDocs(this.getnDocs()+resource.getnDocs());
		Integer temp;
		for (String word : resource.getResourceDescription().keySet()) {
			if (this.getResourceDescription().containsKey(word)) {
				temp = this.getResourceDescription().get(word) + resource.getResourceDescription().get(word);
				if (temp > 0 ) this.getResourceDescription().put(word,temp);
				else  this.getResourceDescription().remove(word);
			} else {
				this.getResourceDescription().put(word, resource.getResourceDescription().get(word));
			}
		}
	}
	
}
